<?php
/**
 * Created by PhpStorm.
 * User: rain
 * Date: 2018/4/6
 * Time: 上午10:53
 */

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Users;
use Illuminate\Support\Facades\Request;


abstract class AuthorizedController extends Controller
{
    //protected $user;
    //
    //public function __construct()
    //{
    //        $this->user = \Illuminate\Support\Facades\Auth::guard('api')->user();
    //
    //}


    /**
     * 获取城市，header 不能传中文，只能 urlecode
     * @return string
     */
    protected function getCity()
    {
        $cityName = Request::header('API-CITY', '%E4%B8%8A%E6%B5%B7%E5%B8%82');

        return urldecode($cityName);
    }


    /**
     * 获取省份
     * @return string
     */
    protected function getProvince()
    {
        $city = $this->getCity();
        $province = '上海市';
        if ($city == '广州市'){
            $province = '广东省';
        }

        return $province;

    }

}